import 'package:flutter/material.dart';
import 'package:ichinesereader/utils/log.dart';
import 'package:ichinesereader/widgets/tabs/leaderBoardClass.dart';
import 'package:ichinesereader/widgets/tabs/leaderBoardWorld.dart';
import 'package:get/get.dart';
import 'package:hive_flutter/hive_flutter.dart';
import 'package:ichinesereader/constants.dart';
import 'package:ichinesereader/controller/cache.dart';

class LeaderBoardPage extends StatelessWidget {
  final box = Hive.box('appconfig');
  @override
  Widget build(BuildContext context) {
    Log.debug('build LeaderBoardPage');
    bool isStudent = box.get(CacheManagerKey['nanhairole'].toString()) ==
        Constants.NanhaiRole_Student;
    return Scaffold(
        body: Container(
      child: isStudent
          ? DefaultTabController(
              length: 2,
              child: Scaffold(
                appBar: AppBar(
                  bottom: TabBar(
                    indicatorColor: Theme.of(context).primaryColorLight,
                    indicatorSize: TabBarIndicatorSize.label,
                    indicatorWeight: 6,
                    tabs: [
                      Tab(
                        child: Text(
                          'World Ranking'.tr,
                          style: TextStyle(
                            color: Theme.of(context).primaryColorLight,
                            letterSpacing: 1.0,
                            fontWeight: FontWeight.bold,
                          ),
                        ),
                      ),
                      Tab(
                        child: Text(
                          'Class Ranking'.tr,
                          style: TextStyle(
                            color: Theme.of(context).primaryColorLight,
                            letterSpacing: 1.0,
                            fontWeight: FontWeight.bold,
                          ),
                        ),
                      ),
                      // Tab(icon: Icon(Icons.map_rounded)),
                      // Tab(icon: Icon(Icons.class__rounded))
                    ],
                  ),
                  title: Text('Leader Board'.tr),
                ),
                body: TabBarView(
                  children: [
                    LeaderBoardWorldTab(),
                    LeaderBoardClassTab(),
                  ],
                ),
              ),
            )
          : DefaultTabController(
              length: 1,
              child: Scaffold(
                appBar: AppBar(
                  bottom: TabBar(
                    indicatorWeight: 1,
                    tabs: [
                      Tab(
                        icon: Icon(Icons.map_rounded),
                      ),
                    ],
                  ),
                  title: Text('Leader Board'.tr),
                ),
                body: TabBarView(
                  children: [
                    LeaderBoardWorldTab(),
                  ],
                ),
              ),
            ),
    ));
  }
}
